<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 数组是有序的 顺序变化会影响结果
        let [c, a, b] = [1, 2, 3];
        console.log(a, b, c);

        // 可以是无序的 结果不受顺序的影响
        let { age: myAge, name: myName, job: myJob } = { name: 'wangwu', age: 18, sex: 'nan' };
        console.log(myAge, myName, myJob);
        let { id: myId, say: sayFn } = {
            id: 4,
            say: function () {
                console.log('hello, id4');
            }
        }
        console.log(myId);
        sayFn()


        let { log: log1, dir: dir } = console;
        log1(myAge)

        let obj = {
            list: ['aa', 'bb', 'cc'],
            hobby: {
                ball: ['篮球', '足球', '乒乓球'],
                fruits: ['榴莲', '百香果', '杨桃'],
                songs: ['单身情歌', ['只因太美', '学猫叫']]
            }
        }
        // 提取复杂结构中的数据 --- 获取 足球、学猫叫
        let {
            hobby: {
                ball: [ball1, ball2],
                songs: [s1, [s21, s22]]
            }
        } = obj;
        console.log(ball2);
        console.log(s22);
    </script>
</body>

</html>